<?php namespace App\Exceptions;
/**
 * Created by PhpStorm.
 * User: zeoepan
 * Date: 2015/8/5
 * Time: 23:44
 */

use Exception;

/**
 * Class UserInfoAuthException      用户信息认证异常处理
 * @package App\Exceptions
 */
class UserInfoAuthException extends Exception{
    /**
     * 参数定义
     * userIdExists         表示投资者的user_id不存在
     * userInfoAuthFails    表示已经验证过，但是验证失败
     * UserInfoAuthPasses   表示已经验证过，但是验证成功
     */
    const NouserId = 0x01;
    const UserInfoAuthFails = 0x02;
    const UserInfoAuthPasses = 0x03;

    public function __construct($code, array $data = [], Exception $previous = null)
    {
        switch ($code) {
            case self::NouserId:
                $message = trans('exception.user_info_auth.no_user_id', ['user_id' => array_get($data, 'user_id')]);
                break;
            case self::UserInfoAuthFails:
                $message = trans('exception.user_info_auth.user_info_auth_fails');
                break;
            case self::UserInfoAuthPasses:
                $message = trans('exception.user_info_auth.user_info_auth_passes');
                break;
            default:
                $message = trans('general.unknown_exception');
                break;
        }

        parent::__construct($message, $code, $previous);
    }
}
